package org.desktop.diskutils.components.treemap.actions;

import prefuse.action.assignment.ColorAction;
import prefuse.util.ColorLib;
import prefuse.visual.NodeItem;
import prefuse.visual.VisualItem;

/**
 * Set the stroke color for drawing treemap node outlines. A graded
 * grayscale ramp is used, with higer nodes in the tree drawn in lighter
 * shades of gray.
 */
public class BorderColorAction extends ColorAction {

	public BorderColorAction(String group) {
		super(group, VisualItem.STROKECOLOR);
	}

	public int getColor(VisualItem item) {
		NodeItem nitem = (NodeItem) item;
		if (nitem.isHover())
			return ColorLib.rgb(99, 130, 191);

		int depth = nitem.getDepth();
		if (depth < 2) {
			return ColorLib.gray(100);
		} else if (depth < 4) {
			return ColorLib.gray(75);
		} else {
			return ColorLib.gray(50);
		}
	}
}
